

import request from '/@/utils/request';
import other from '/@/utils/other';

export interface Organization {
  Value: string;
  Text: string;
  Disabled: boolean;
  Selected?: boolean;
  ParentId?: string;
}

export interface QueryParams {
  groupId?: string; // 部门ID
  auth?: boolean; // 是否启用认证 默认false
}

export interface QueryGroup {
  orgId?: string; // 公司ID
  auth?: boolean; // 是否启用认证 默认false
}

export interface QueryTimeline {
  entityId?: string; // 实体ID
}


function commonApi() {
  return {
    //组织/公司
    getOrganizations: (groupId?: string): Promise<Organization[]> => {
      return request({
        url: '/api/common/getorganizations',
        method: 'get',
        params: groupId ? { groupId } : {},
      });
    },
    //部门
    getGroupsTree: (params: QueryGroup): Promise<Organization[]> => {
      return request({
        url: '/api/common/getgroups',
        method: 'get',
        params,
      });
    },
    //岗位
    getJobPositions: (params: QueryParams): Promise<Organization[]> => {
      return request({
        url: '/api/common/getjobpositions',
        method: 'get',
        params,
      });
    },
    //时间线
    getTimeline: (params: QueryTimeline): Promise<Organization[]> => {
      return request({
        url: '/api/common/gettimeline',
        method: 'get',
        params,
      });
    },
    //获取人员信息
    getPersonInfo: (params: QueryParams): Promise<any> => {
      return request({
        url: '/api/_account/getpersoninfo',
        method: 'get',
        params,
      });
    },
    //获取公司信息
    getCompanyInfo: (): Promise<any> => {
      return request({
        url: '/api/common/GetUserCompanies',
        method: 'get',
      });
    },

    // 获取树形物料分组数据
    getMaterialGroupTree: (): Promise<any> => {
      return request({
        url: '/api/common/GetMaterialGroups',
        method: 'get',
      });
    },
  };
}

export { commonApi };